<html>
<head><meta charset="utf-8"><title>Procedural macro spans · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Procedural.20macro.20spans.html">Procedural macro spans</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="208128750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Procedural%20macro%20spans/near/208128750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Procedural.20macro.20spans.html#208128750">(Aug 26 2020 at 18:24)</a>:</h4>
<p>I've written a procedural macro, but I don't think the spans on the generated code are quite right - is there any tooling for debugging this? I thought I remembered reading about something like that...</p>



<a name="208145488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Procedural%20macro%20spans/near/208145488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Procedural.20macro.20spans.html#208145488">(Aug 26 2020 at 20:39)</a>:</h4>
<p><span class="user-mention" data-user-id="295632">@Diggory Blake</span> On nightly, you can pass <code>-Z span-debug</code>, which will make the <code>Debug</code> impl for <code>Span</code> print out actual location information</p>



<a name="208156346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Procedural%20macro%20spans/near/208156346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Procedural.20macro.20spans.html#208156346">(Aug 26 2020 at 22:19)</a>:</h4>
<p>thanks - I'm also having a problem: I would like to replace uses of "self" with a different identifier, but the "visit_mut" functionality of syn doesn't seem to be able to look into macros like <code>println!</code> - is there a way I can force inner macros to be expanded?</p>



<a name="208239591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Procedural%20macro%20spans/near/208239591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Procedural.20macro.20spans.html#208239591">(Aug 27 2020 at 16:12)</a>:</h4>
<p>Do you just need to look at the tokens provided to the macro?</p>



<a name="208239620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Procedural%20macro%20spans/near/208239620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Procedural.20macro.20spans.html#208239620">(Aug 27 2020 at 16:12)</a>:</h4>
<p>or do you actually need to see the code that the macro invocation produces?</p>



<a name="208239739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Procedural%20macro%20spans/near/208239739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Procedural.20macro.20spans.html#208239739">(Aug 27 2020 at 16:13)</a>:</h4>
<p>If it's the former, you should be able to parse the <code>TokenStream</code> from <code>syn::Macro</code> (<a href="https://docs.rs/syn/1.0.39/syn/struct.Macro.html">https://docs.rs/syn/1.0.39/syn/struct.Macro.html</a>)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>